package cn.edu.sjtu.flaw_detection.dto;

import cn.edu.sjtu.flaw_detection.enums.ECNStateEnum;
import cn.edu.sjtu.flaw_detection.vo.TaskVO;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

@Data
@Builder
@JsonInclude(value = JsonInclude.Include.NON_EMPTY)
public class StateDTO {

  private String taskId;
  private String processId;
  private Date time;
  private Integer status;
  private MockData data;

  public static StateDTO ofTaskState(TaskVO taskVO) {
    return StateDTO.builder()
        .processId(taskVO.getProcessId())
        .taskId(taskVO.getTaskId())
        .time(new Date())
        .status(taskVO.getStatus().ordinal())
        .data(MockData.genRandomData())
        .build();
  }

  public static StateDTO ofECNState(ECNStateEnum ecnStateEnum) {
    return StateDTO.builder().time(new Date()).status(ecnStateEnum.ordinal()).build();
  }
}
